
const inquirer = require("inquirer");

inquirer.prompt([
    {
        type:"input",
        message:"请输入你的姓名：",
        name:"name",
    },
    {
      type:"input",
      message:"请输入你的年龄:",
      name:"age",
      default:18
    },
    {
      type:"confirm",
      message:"是否现在监听？",
      name:"watch",
      default:true
    },
    {
      type:"confirm",
      message:"是否能看到？",
      name:"see",
      default:true,
      when: function(answer) {
        return answer.watch
      }
    },
    {
      type:"list",
      message:"请选择一个选项：",
      name:"fruit",
      default:"Apple",
      prefix:"☆☆☆☆",
      suffix:"****",
      choices:[
          "Apple",
          "pear",
          "seee"
      ],
      filter: function (val) { // 使用filter将值变为大写
          return val.toUpperCase();
      }
    },
    {
      type:"checkbox",
      message:"请选择颜色：",
      name:"color",
      choices:[
          {
            name : "red"
          },
          {
            name : "blue"
          },
          {
            name : "green"
          },
          {
            name : "pink",
          },
          {
            name : "orange"
          }
      ]
  }
]).then((answer) => {
    // 用户输入的结果最终会在这里输出
    console.log(answer);
});

